package net.jxiny.oschina.tweet.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import net.jxiny.oschina.R;
import net.jxiny.oschina.synthetical.Adapter.EnglishAdapter;
import net.jxiny.oschina.synthetical.enyity.English;
import net.jxiny.oschina.tweet.Adapter.MusicAdapter;
import net.jxiny.oschina.tweet.enyity.Music;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class MusicFragment extends Fragment {
    private Unbinder binder;
    @BindView(R.id.recyclerView_3)
    RecyclerView recyclerView3;
    private List<Music> lists = new ArrayList<>();

    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_music, container, false);
        binder = ButterKnife.bind(this, view);
        return view;
    }


    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Music music = new Music();
        //TODO 假数据， 后续改为网络请求**********************
        for (int i=0;i<30;i++) {
            lists.add(music);
        }
        //*********************************************
        RecyclerView.LayoutManager manager = new LinearLayoutManager(getActivity(),RecyclerView.VERTICAL,false);
        recyclerView3.setLayoutManager(manager);
        recyclerView3.setAdapter(new MusicAdapter(R.layout.item_music,lists));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binder.unbind();
    }
}
